package com.ksd.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ksd.common.annotation.Log;
import com.ksd.common.core.controller.BaseController;
import com.ksd.common.core.domain.AjaxResult;
import com.ksd.common.core.page.TableDataInfo;
import com.ksd.common.enums.BusinessType;
import com.ksd.common.utils.StringUtils;
import com.ksd.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ksd.system.domain.SysSynchData;
import com.ksd.system.service.ISysSynchDataService;

/**
 * 内容同步记录Controller
 * 
 * @author y.wu
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/system/synchData")
public class SysSynchDataController extends BaseController
{
    @Autowired
    private ISysSynchDataService sysSynchDataService;

    /**
     * 查询内容同步记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSynchData sysSynchData)
    {
        startPage();
        List<SysSynchData> list = sysSynchDataService.selectSysSynchDataList(sysSynchData);
        return getDataTable(list);
    }

    /**
     * 导出内容同步记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:export')")
    @Log(title = "内容同步记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSynchData sysSynchData)
    {
        List<SysSynchData> list = sysSynchDataService.selectSysSynchDataList(sysSynchData);
        ExcelUtil<SysSynchData> util = new ExcelUtil<SysSynchData>(SysSynchData.class);
        util.exportExcel(response, list, "内容同步记录数据");
    }

    /**
     * 获取内容同步记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSynchDataService.selectSysSynchDataById(id));
    }

    /**
     * 新增内容同步记录
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:add')")
    @Log(title = "内容同步记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSynchData sysSynchData)
    {
        return toAjax(sysSynchDataService.insertSysSynchData(sysSynchData));
    }

    /**
     * 修改内容同步记录
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:edit')")
    @Log(title = "内容同步记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSynchData sysSynchData)
    {
        return toAjax(sysSynchDataService.updateSysSynchData(sysSynchData));
    }

    /**
     * 删除内容同步记录
     */
    @PreAuthorize("@ss.hasPermi('system:synchData:remove')")
    @Log(title = "内容同步记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSynchDataService.deleteSysSynchDataByIds(ids));
    }
    @Log(title = "操作日志", businessType = BusinessType.CLEAN)
    @DeleteMapping("/clean")
    public AjaxResult clean()
    {
        sysSynchDataService.cleanSynchData();
        return success();
    }
}
